<?php

Yii::import('system.test.CDbFixtureManager');

/**
 * @package X2CRM.components
 */
class X2FixtureManager extends CDbFixtureManager {

	/**
	 * Override of {@link CDbFixtureManager}'s resetTable 
	 * 
	 * Permits array-style definition of fixtures much like fixture files themselves
	 */
	public function resetTable($tableName) {
		$initFile = $this->basePath . DIRECTORY_SEPARATOR . $tableName . $this->initScriptSuffix;
		if (is_file($initFile)) {
			$tbl_data = require($initFile);
			if (is_array($tbl_data)) {
				Yii::app()->db->createCommand()->truncateTable($tableName);
				foreach ($tbl_data as $rec)
					Yii::app()->db->createCommand()->insert($tableName, $rec);
			}
		} else
			$this->truncateTable($tableName);
	}

}

?>
